-
Notifications
You must be signed in to change notification settings - Fork 165
feat(BA-3668): remove unnecessary informations from model service JWT #7705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
.feature.md -> 7705.feature.md Co-authored-by: octodog <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request refactors JWT token generation for model service endpoints by centralizing the logic in the Circuit model and reducing token payload size. The changes move JWT creation from the endpoint API to a new model method while removing unnecessary and sensitive data from the token payload.
- Centralized JWT generation logic in a new
Circuit.generate_jwtmethod - Reduced JWT payload size by removing
configandroute_infofields - Removed direct
jwtlibrary usage from the endpoint API
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/ai/backend/appproxy/coordinator/models/circuit.py |
Added generate_jwt method to centralize JWT creation with reduced payload; added jwt import |
src/ai/backend/appproxy/coordinator/api/endpoint.py |
Refactored to use the new Circuit.generate_jwt method; removed jwt import |
changes/.feature.md |
Documentation of the feature to reduce JWT token size |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
| payload["user"] = str(created_user) | ||
| payload["exp"] = exp | ||
| # mask unrelated & sensitive information | ||
| del payload["config"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has config field been removed from Circuit ORM schema? If then, this could raise error
resolves #7704 (BA-3668).
This pull request focuses on reducing the size of JWT tokens generated for model service endpoints by removing unnecessary information and centralizing the logic for JWT creation. The changes streamline the payload, mask sensitive data, and move JWT generation to the
Circuitmodel for better maintainability.JWT Generation Improvements:
generate_jwtmethod to theCircuitmodel to create JWT tokens with only essential information, removing unrelated and sensitive fields such asconfigandroute_info. (src/ai/backend/appproxy/coordinator/models/circuit.py, src/ai/backend/appproxy/coordinator/models/circuit.pyR417-R431)generate_jwtmethod, ensuring a smaller and cleaner JWT payload. (src/ai/backend/appproxy/coordinator/api/endpoint.py, src/ai/backend/appproxy/coordinator/api/endpoint.pyL303-R304)Codebase Cleanup:
jwtlibrary from the endpoint API, consolidating JWT logic in the model layer. (src/ai/backend/appproxy/coordinator/api/endpoint.py, src/ai/backend/appproxy/coordinator/api/endpoint.pyL9)jwtimport to the model file to support the new centralized JWT generation method. (src/ai/backend/appproxy/coordinator/models/circuit.py, src/ai/backend/appproxy/coordinator/models/circuit.pyR5)Documentation:
changes/.feature.md, changes/.feature.mdR1)